﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Heyu.Utility
{
    /// <summary>
    /// 正则表达式
    /// </summary>
    public class RegexUtility
    {
        /// <summary>
        /// 邮箱
        /// </summary>
        public const string EMAIL = @"^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$";
        /// <summary>
        /// 整数
        /// </summary>
        public const string INT = @"^[0-9]\d*$";
        /// <summary>
        /// 正整数
        /// </summary>
        public const string PINT = @"^[0-9]*[1-9][0-9]*$";
        /// <summary>
        /// 负整数
        /// </summary>
        public const string NINT = @"^-[0-9]*[1-9][0-9]*$";
        /// <summary>
        /// 非负整数（正整数 + 0）
        /// </summary>
        public const string NOTNINT = @"^[1-9]d*|0$";
        /// <summary>
        /// 座机号
        /// </summary>
        public const string TELEPHONE = @"^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$";
        /// <summary>
        /// 手机号
        /// </summary>
        public const string MOBILEPHONE = @"^1[3|4|5|7|8][0-9]\d{8}$";
        /// <summary>
        /// 用户名
        /// </summary>
        public const string USERNAME = @"^[a-zA-Z][a-zA-Z0-9_]{3,15}$";
        /// <summary>
        /// 邮编
        /// </summary>
        public const string ZIP = @"^[1-9][0-9]{5}$";
        /// <summary>
        /// 中国邮政编码（6位数字）
        /// </summary>
        public const string POSTCODE = @"^[1-9][0-9]{5}$";
        /// <summary>
        /// 数字
        /// </summary>
        public const string NUMBER = @"^(0|([1-9]+[0-9]*))(.[0-9]+)?$";
        /// <summary>
        /// 
        /// </summary>
        public const string DECIMAL = @"^(-?\d+)(\.\d+)?$";
        /// <summary>
        /// 货币
        /// </summary>
        public const string MONEY = @"^([0-9])$";
        /// <summary>
        /// 网址
        /// </summary>
        public const string WEBSITE = @"(http://|https://){0,1}[\w\/\.\?\&\=]+";
        /// <summary>
        /// 传真
        /// </summary>
        public const string FAX = @"^[+]{0,1}([0-9]){1,3}[ ]?([-]?(([0-9])|[ ]){1,12})+$";
        /// <summary>
        /// 数字与字母
        /// </summary>
        public const string NANDL = @"[a-zA-Z0-9]";
        /// <summary>
        /// 中文字符
        /// </summary>
        public const string CHINESE = @"[\u4e00-\u9fa5]";
        /// <summary>
        /// 身份证号码
        /// </summary>
        public const string IDNUMBER = @"^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X|x)$";
        /// <summary>
        /// 腾讯QQ号（从10000开始）
        /// </summary>
        public const string QQ = @"[1-9][0-9]{4,}";
        /// <summary>
        /// 日期验证 含闰年
        /// </summary>
        public const string DATETIME = @"^((((19|20)\d{2})-(0?(1|[3-9])|1[012])-(0?[1-9]|[12]\d|30))|(((19|20)\d{2})-(0?[13578]|1[02])-31)|(((19|20)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))-0?2-29))$";

        /// <summary>
        /// 日期
        /// </summary>
        public const string DATE = @"^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$";

        /// <summary>
        /// 昵称
        /// </summary>
        public const string NICKNAME = "^([\u4E00-\u9FA5A-Za-z0-9])*$";

        /// <summary>
        /// 人名
        /// </summary>
        public const string NAME = "^([\u4E00-\u9FA5]){2,10}$";
    }
}
